From: Brion Vibber Date: Tue, 15 Apr 2008 19:02:12 +0000 (+0000) Subject: * (bug 13725) Upload form watch checkbox state set correctly with wpDestFile X-Git-Tag: 1.31.0-rc.0~48294 X-Git-Url: http://git.cyclocoop.org/%7D%7Cconcat%7B?a=commitdiff_plain;h=57c6273b8c7324153ff9b16488974385b6cab8c0;p=lhc%2Fweb%2Fwiklou.git * (bug 13725) Upload form watch checkbox state set correctly with wpDestFile r33330 just disabled the check for wpDestFile, so that the 'watch pages i create' setting would watch *all* uploads. The system now checks the actual value, so it sets the watch checkbox if the requested file doesn't exist locally and you have it set for creations, or if you've already got the file watched. There are still some minor issues: * Since you have the chance to change the target filename on the form, the initial checkbox state can get out of sync if you switch from an empty file to an existing file or vice-versa. * Unlike the edit form, the upload form doesn't _unwatch_ a previously-watched page when the box is unchecked. --- diff --git a/RELEASE-NOTES b/RELEASE-NOTES index 1fbc6c4be9..381ef63582 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -184,6 +184,8 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN * (bug 13728) Don't trim initial whitespace during section edits * (bug 13727) Don't delete log entries from recentchanges on page deletion * (bug 13752) Section redirects now works again +* (bug 13725) Upload form watch checkbox state set correctly with wpDestFile + === API changes in 1.13 === diff --git a/includes/SpecialUpload.php b/includes/SpecialUpload.php index 5e79e63af9..f0a36d6155 100644 --- a/includes/SpecialUpload.php +++ b/includes/SpecialUpload.php @@ -1016,8 +1016,7 @@ wgUploadAutoFill = {$autofill}; $encDestName = htmlspecialchars( $this->mDesiredDestName ); - $watchChecked = - ( $wgUser->getOption( 'watchdefault' ) || $wgUser->getOption( 'watchcreations' ) ) + $watchChecked = $this->watchCheck() ? 'checked="checked"' : ''; $warningChecked = $this->mIgnoreWarning ? 'checked' : ''; @@ -1192,6 +1191,35 @@ wgUploadAutoFill = {$autofill}; } /* -------------------------------------------------------------- */ + + /** + * See if we should check the 'watch this page' checkbox on the form + * based on the user's preferences and whether we're being asked + * to create a new file or update an existing one. + * + * In the case where 'watch edits' is off but 'watch creations' is on, + * we'll leave the box unchecked. + * + * Note that the page target can be changed *on the form*, so our check + * state can get out of sync. + */ + function watchCheck() { + global $wgUser; + if( $wgUser->getOption( 'watchdefault' ) ) { + // Watch all edits! + return true; + } + + $local = wfLocalFile( $this->mDesiredDestName ); + if( $local && $local->exists() ) { + // We're uploading a new version of an existing file. + // No creation, so don't watch it if we're not already. + return $local->getTitle()->userIsWatching(); + } else { + // New page should get watched if that's our option. + return $wgUser->getOption( 'watchcreations' ); + } + } /** * Split a file into a base name and all dot-delimited 'extensions'